package com.mice.game.core{
	import com.mice.event.GameEvent;
	
	import flash.events.EventDispatcher;

	public class Player extends EventDispatcher{
		
		public static const TEAM_RED:int = 1;
		public static const TEAM_BLUE:int = 2;
		
		/**
		 * 红方/蓝方
		 */		
		public var team:int;
		
		/**
		 * 精力恢复速率.每*帧恢复一点,同样会被初始化属性和技能点影响
		 */		
		public var energyRecoverInternal:int;
		
		/**
		 * 精力每次回复的点数
		 */		
		public var energyRecoverValue:int = 5;
		
		/**
		 * 最大精力, 同样会被初始化属性和技能点影响
		 */		
		public var maxEnergy:int = 50;
		
		/**
		 * 精力值,又初始化属性和技能点影响
		 */
		private var _energy:int;
		
		public function Player(){}
		
		/**
		 * 精力值,又初始化属性和技能点影响
		 */
		public function get energy():int{
			return _energy;
		}

		public function set energy(value:int):void{
			_energy = value;
			var e:GameEvent = new GameEvent(GameEvent.UPDATE_ENERGY);
			dispatchEvent(e);
		}
		
		/**
		 * 倒计时回复精力
		 */		
		public function autoRecoverEnergy():void{
			if(_energy >= maxEnergy)return;
			energy += energyRecoverValue;
		}
		
		/**
		 * 产兵,技能,会消耗精力点
		 */		
		public function useEnergy(value:int):void{
			if (_energy < value)return;
			energy -= value;
		}
	}
}